<template>
  
  <list-view v-ref:listview>
    <comment-item v-for="cmt in comments" :comment="cmt"></comment-item>
  </list-view>

</template>

<script>

  import { ListView } from '../components'
  import CommentItem from './comment-item.vue'
  import Store from '../store'
  import _ from 'lodash'

  export default {

    components: { ListView, CommentItem },

    data() {
      return {
        comments: []
      }
    },

    ready() {
      let _this = this
      Store.fetchComments({id: 69796, catalog: 1}).then((comments) => {
        comments = _.map(comments, (cmt)=> {
          cmt.refers = _.sortBy(cmt.refers, (refer) => {
            return -refer  
          })
          return cmt
        })
        _this.$set('comments', comments)
        console.log(comments)
      })
      // this.$refs.listview.duration(0.01)
    }

  }
  
</script>